enhance validate filter to report on track segments. (#1308)
authortsteven4 <13596209+tsteven4@users.noreply.github.com>
Thu, 1 Aug 2024 12:52:03 +0000 (06:52 -0600)
committerGitHub <noreply@github.com>
Thu, 1 Aug 2024 12:52:03 +0000 (06:52 -0600)
reference/validate_debug.log
validate.cc
validate.h

index 85e4f47e9255687e0a3a537ed91e766d2e3e27cd..55630cc0c22b5fc7657e0d673fb1933868f0bec4 100644 (file)
@@ -3,11 +3,11 @@ Processing waypts
 point ct: 2, waypt_count: 2
 
 Processing routes
-route 0 ct: 2, waypt_count: 2
-route head ct: 1, route_count: 1
+route 0 ct: 2, waypt_count: 2, segments 1
+route head ct: 1, route_count: 1, total segment count: 1
 total route point ct: 2, route_waypt_count: 2
 
 Processing tracks
-track 0 ct: 2, waypt_count: 2
-track head ct: 1, track_count: 1
+track 0 ct: 2, waypt_count: 2, segments 1
+track head ct: 1, track_count: 1, total segment count: 1
 total track point ct: 2, track_waypt_count: 2
index f3d20d6648069a4a0b154746ad0f15c5e331350f..9c54f34ca85c8957fdd2826acfa5ec8c0b7052ef 100644 (file)
 void ValidateFilter::validate_head(const route_head* /*unused*/)
 {
   head_ct += 1;
-  segment_ct_start = point_ct;
+  point_ct = 0;
+  segment_ct = 0;
 }
 
 void ValidateFilter::validate_head_trl(const route_head* header)
 {
-  int segment_waypt_ct = point_ct - segment_ct_start;
+  total_point_ct += point_ct;
+  total_segment_ct += segment_ct;
   if (debug) {
-    fprintf(stderr, "%s %d ct: %d, waypt_count: %d\n", segment_type, header->rte_num,  segment_waypt_ct, header->rte_waypt_ct());
+    fprintf(stderr, "%s %d ct: %d, waypt_count: %d, segments %d\n", segment_type, header->rte_num,  point_ct, header->rte_waypt_ct(), segment_ct);
   }
-  if (!debug && (segment_waypt_ct != header->rte_waypt_ct())) {
-    fatal(MYNAME ":%s %d count mismatch, expected %d, actual %d\n", segment_type, header->rte_num, header->rte_waypt_ct(), segment_waypt_ct);
+  if (!debug && (point_ct != header->rte_waypt_ct())) {
+    fatal(MYNAME ":%s %d count mismatch, expected %d, actual %d\n", segment_type, header->rte_num, header->rte_waypt_ct(), point_ct);
   }
 }
 
-void ValidateFilter::validate_point(const Waypoint* /*unused*/)
+void ValidateFilter::validate_point(const Waypoint* wpt)
 {
   point_ct += 1;
+  if (wpt->wpt_flags.new_trkseg) {
+    segment_ct += 1;
+  }
 }
 
 void ValidateFilter::process()
@@ -71,39 +76,41 @@ void ValidateFilter::process()
   }
 
   head_ct = 0;
-  point_ct = 0;
+  total_point_ct = 0;
+  total_segment_ct = 0;
   segment_type = "route";
   if (debug) {
     fprintf(stderr, "\nProcessing routes\n");
   }
   route_disp_all(validate_head_f, validate_head_trl_f, validate_point_f);
   if (debug) {
-    fprintf(stderr, "route head ct: %d, route_count: %d\n", head_ct, route_count());
-    fprintf(stderr, "total route point ct: %d, route_waypt_count: %d\n", point_ct, route_waypt_count());
+    fprintf(stderr, "route head ct: %d, route_count: %d, total segment count: %d\n", head_ct, route_count(), total_segment_ct);
+    fprintf(stderr, "total route point ct: %d, route_waypt_count: %d\n", total_point_ct, route_waypt_count());
   }
   if (!debug && (head_ct != route_count())) {
     fatal(MYNAME ":Route count mismatch, expected %d, actual %d\n", route_count(), head_ct);
   }
-  if (!debug && (point_ct != route_waypt_count())) {
-    fatal(MYNAME ":Total route waypoint count mismatch, expected %d, actual %d\n", route_waypt_count(), point_ct);
+  if (!debug && (total_point_ct != route_waypt_count())) {
+    fatal(MYNAME ":Total route waypoint count mismatch, expected %d, actual %d\n", route_waypt_count(), total_point_ct);
   }
 
   head_ct = 0;
-  point_ct = 0;
+  total_point_ct = 0;
+  total_segment_ct = 0;
   segment_type = "track";
   if (debug) {
     fprintf(stderr, "\nProcessing tracks\n");
   }
   track_disp_all(validate_head_f, validate_head_trl_f, validate_point_f);
   if (debug) {
-    fprintf(stderr, "track head ct: %d, track_count: %d\n", head_ct, track_count());
-    fprintf(stderr, "total track point ct: %d, track_waypt_count: %d\n", point_ct, track_waypt_count());
+    fprintf(stderr, "track head ct: %d, track_count: %d, total segment count: %d\n", head_ct, track_count(), total_segment_ct);
+    fprintf(stderr, "total track point ct: %d, track_waypt_count: %d\n", total_point_ct, track_waypt_count());
   }
   if (!debug && (head_ct != track_count())) {
     fatal(MYNAME ":Track count mismatch, expected %d, actual %d\n", track_count(), head_ct);
   }
-  if (!debug && (point_ct != track_waypt_count())) {
-    fatal(MYNAME ":Total track waypoint count mismatch, expected %d, actual %d\n", track_waypt_count(), point_ct);
+  if (!debug && (total_point_ct != track_waypt_count())) {
+    fatal(MYNAME ":Total track waypoint count mismatch, expected %d, actual %d\n", track_waypt_count(), total_point_ct);
   }
 
   if (checkempty) {
index 7a91388dcc9e090ea9684534992f0250b018a1ed..8c81c85870224b292d297eb4afdc62dbd8588c3e 100644 (file)
@@ -45,8 +45,10 @@ private:
   char* opt_checkempty{};
   bool checkempty{};
   int point_ct{};
+  int total_point_ct{};
+  int segment_ct{};
+  int total_segment_ct{};
   int head_ct{};
-  int segment_ct_start{};
   const char* segment_type{};
   QVector<arglist_t> args = {
     {